import { isMobile } from '@/common/js/util'

export default {
  watch: {
    $route (route) {
      if (window.device === 'mobile') {
        console.log('$route mobile')
      }
    }
  },
  beforeMount () {
    window.addEventListener('resize', this.resizeHandler)
  },
  mounted () {
    this.isMobile = isMobile()
    window.device = this.isMobile ? 'mobile' : 'desktop'
    if (this.isMobile) {
      console.log('mounted mobile')
    }
  },
  methods: {
    resizeHandler () {
      this.isMobile = isMobile()
      window.device = this.isMobile ? 'mobile' : 'desktop'
      if (this.isMobile) {
        console.log('resize', window.device)
      }
    }
  }
}
